
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'workteam/accountlog/index/',
                    add_url: 'workteam/accountlog/add',
                    edit_url: '',
                    del_url: 'workteam/accountlog/del',
                    multi_url: '',
                    table: '',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {field: 'id', title: 'ID'},
                        {field: 'project.number', title: __('项目编号'),operate:false,align: 'left'},
                        {field: 'project.name', title: __('项目'),operate:false,align: 'left'},
                        {field: 'project_id', title: __('项目'),addclass: 'selectpage',visible:false,
                            extend: "data-source='workteam/project/index' data-field='name'"},
                        {
                            field: 'type',
                            title: __('类型'),
                            formatter: Table.api.formatter.status,
                            searchList: Config.typeList
                        },
                        {field: 'money', title: __('费用'), operate: "LIKE"},
                        {field: 'memo', title: __('说明'), operate: 'LIKE',},
                        {
                            field: 'pay_time',
                            title: __('支出时间'),
                            formatter: Table.api.formatter.datetime,
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            sortable: true
                        },
                        {
                            field: 'create_time',
                            title: __('创建时间'),
                            formatter: Table.api.formatter.datetime,
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            sortable: true
                        },
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,}

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"), function(data, ret){
                    //绑定时间
                    Fast.api.close(data);//在这里关闭当前弹窗
                });
            },
        }
    };

    return Controller;
});


